australian crabs:

library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tm)
## Loading required package: NLP
## 
## Attaching package: 'NLP'
## The following object is masked from 'package:ggplot2':
## 
##     annotate
library(wordcloud)
## Loading required package: RColorBrewer
library(RColorBrewer)
library(crosstalk)
library(GGally)
library(htmltools)
crabs<- read.csv("australian-crabs.csv")
t <- SharedData$new(crabs)

scatterCrab <- plot_ly(t, x = ~CL, y = ~RW) %>%
  add_markers(color = I("black"))
barCrab <-plot_ly(t, x=~sex)%>%add_histogram()%>%layout(barmode="overlay")
bscols(widths=c(2, NA),filter_slider("FL", "Frontal Lobe", t, ~FL)
        ,subplot(scatterCrab,barCrab)%>%
  highlight(on="plotly_select", dynamic=T, persistent = T, opacityDim = I(1))%>%hide_legend())
## Adding more colors to the selection color palette.
## We recommend setting `persistent` to `FALSE` (the default) because persistent selection mode can now be used by holding the shift key (while triggering the `on` event).
## Setting the `off` event (i.e., 'plotly_relayout') to match the `on` event (i.e., 'plotly_selected'). You can change this default via the `highlight()` function.
ButtonsX=list()
for (i in 4:7){
  ButtonsX[[i-3]]= list(method = "restyle",
                        args = list( "x", list(crabs[[i]])),
                        label = colnames(crabs)[i])
}
ButtonsY=list()
for (i in 4:7){
  ButtonsY[[i-3]]= list(method = "restyle",
                        args = list( "y", list(crabs[[i]])),
                        label = colnames(crabs)[i])
}
p <- plot_ly(t, x = ~CL, y = ~CW, alpha = 0.8) %>%
  add_markers() %>%
  layout(xaxis=list(title=""), yaxis=list(title=""),
    title = "Select variable:",
    updatemenus = list(
      list(y=0.9, buttons = ButtonsX),
      list(y=0.6, buttons = ButtonsY)
    )  )

p